package nz.example.uni.beaninfo;

import java.beans.IntrospectionException;
import java.beans.PropertyDescriptor;
import java.beans.SimpleBeanInfo;

import nz.example.uni.Person;

public class PersonBeanInfo extends SimpleBeanInfo {

	@SuppressWarnings("unchecked")
	private Class personClass = Person.class;

	@Override
	public PropertyDescriptor[] getPropertyDescriptors() {
		PropertyDescriptor name = null, dob = null, address = null, male=null;

        try {
            name = new PropertyDescriptor("name", personClass);
            name.setDisplayName("The persons full name");
            name.setPreferred(true);

            dob = new PropertyDescriptor("dob", personClass);
            dob.setDisplayName("The persons date of birth");
            dob.setPreferred(true);

            address = new PropertyDescriptor("address", personClass);
            address.setDisplayName("The persons address");
            address.setPreferred(true);
            
            male = new PropertyDescriptor("male", personClass);
            male.setDisplayName("Is this person male");
            male.setPreferred(true);

        } catch (IntrospectionException ie) {
        	ie.printStackTrace();
        }

        PropertyDescriptor[] result = {name, dob, address,male};
        return result;
	}
}
